<div>
    <div ng-if="!dialog.orderedFields || dialog.orderedFields.length === 0">
        <em>No aditional information have been specified</em>
    </div>

    <dl class="dl-horizontal clear"
        ng-repeat="k in dialog.orderedFields"
        ng-init="fieldDef = dialog.customFieldsCache.get(k);">
        <dt class="pull-left" uib-tooltip="{{fieldDef.description}}">{{fieldDef.name}}</dt>
        <dd ng-if="fieldDef.options.length > 0">
            <updatable-select
                options="fieldDef.options"
                on-update="dialog.updateField(dialog.getCustomFieldName(fieldDef), newValue)"
                value="dialog.event.customFields[fieldDef.reference][fieldDef.type]"></updatable-select>
        </dd>

        <dd ng-if="fieldDef.options.length === 0" ng-switch="fieldDef.type">
            <updatable-simple-text ng-switch-when="string"
                input-type="text"
                on-update="dialog.updateField(dialog.getCustomFieldName(fieldDef), newValue)"
                value="dialog.event.customFields[fieldDef.reference][fieldDef.type]"></updatable-simple-text>

            <updatable-date ng-switch-when="date"
                on-update="dialog.updateField(dialog.getCustomFieldName(fieldDef), newValue)"
                value="dialog.event.customFields[fieldDef.reference][fieldDef.type]"></updatable-date>

            <updatable-simple-text ng-switch-when="number"
                input-type="number"
                on-update="dialog.updateField(dialog.getCustomFieldName(fieldDef), newValue)"
                value="dialog.event.customFields[fieldDef.reference][fieldDef.type]"></updatable-simple-text>

            <updatable-boolean ng-switch-when="boolean"
                input-type="number"
                on-update="dialog.updateField(dialog.getCustomFieldName(fieldDef), newValue)"
                value="dialog.event.customFields[fieldDef.reference][fieldDef.type]"></updatable-boolean>

            <span ng-switch-default>Not Editable</span>
        </dd>
    </dl>
</div>
